//
// Copyright 2017 Google Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions://
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

@import "./common";
@import "../packages/mdc-form-field/mdc-form-field";
@import "../packages/mdc-textfield/mdc-text-field";

// stylelint-disable selector-class-pattern
.demo-text-field-custom-colors:not(.mdc-text-field--invalid) {
  $idle-border: rgba(blue, .38);
  $hover-border: rgba(blue, .6);
  $focused-border: rgba(blue, 1);

  @include mdc-text-field-bottom-line-color($idle-border);
  @include mdc-text-field-hover-bottom-line-color($hover-border);
  @include mdc-text-field-line-ripple-color($focused-border);
  @include mdc-text-field-ink-color(black);
  @include mdc-text-field-label-color(rgba(blue, .5));
  @include mdc-text-field-outline-color($idle-border);
  @include mdc-text-field-hover-outline-color($hover-border);
  @include mdc-text-field-focused-outline-color($focused-border);
  @include mdc-text-field-helper-text-color($idle-border);
  @include mdc-text-field-textarea-stroke-color($idle-border);
  @include mdc-text-field-icon-color($hover-border);
  @include mdc-text-field-caret-color($focused-border);

  &.mdc-text-field--focused {
    @include mdc-text-field-label-color(rgba(blue, .87));
    @include mdc-text-field-icon-color($focused-border);
  }
}

.demo-textarea:not(.mdc-text-field--invalid) {
  $idle-border: rgba(blue, .38);
  $hover-border: rgba(blue, .6);
  $focused-border: rgba(blue, 1);

  @include mdc-text-field-ink-color(black);
  @include mdc-text-field-label-color(rgba(blue, .5));
  @include mdc-text-field-textarea-stroke-color($idle-border);
  @include mdc-text-field-caret-color($focused-border);

  &.mdc-text-field--focused {
    @include mdc-text-field-label-color(rgba(blue, .87));
    @include mdc-text-field-textarea-stroke-color($focused-border);
  }
}

.demo-textarea.mdc-text-field--invalid {
  @include mdc-text-field-ink-color(orange);
  @include mdc-text-field-label-color(rgba(orange, .5));
  @include mdc-text-field-textarea-stroke-color(rgba(orange, .38));
  @include mdc-text-field-caret-color(orange);

  &.mdc-text-field--focused {
    @include mdc-text-field-label-color(rgba(orange, .87));
    @include mdc-text-field-textarea-stroke-color(orange);
  }
}

.demo-fullwidth-input:not(.mdc-text-field--invalid) {
  @include mdc-text-field-fullwidth-bottom-line-color(rgba(blue, .38));
  @include mdc-text-field-ink-color(black);
  @include mdc-text-field-label-color(rgba(blue, .5));
  @include mdc-text-field-line-ripple-color(blue);
  @include mdc-text-field-caret-color(blue);

  &.mdc-text-field--focused {
    @include mdc-text-field-label-color(rgba(blue, .87));
  }
}

.demo-fullwidth-input.mdc-text-field--invalid {
  @include mdc-text-field-fullwidth-bottom-line-color(rgba(orange, .38));
  @include mdc-text-field-ink-color(orange);
  @include mdc-text-field-label-color(rgba(orange, .5));
  @include mdc-text-field-line-ripple-color(orange);
  @include mdc-text-field-caret-color(orange);

  &.mdc-text-field--focused {
    @include mdc-text-field-label-color(rgba(orange, .87));
    @include mdc-text-field-fullwidth-bottom-line-color(orange);
  }
}

.demo-text-field-custom-error-colors.mdc-text-field--invalid {
  $idle-border: rgba(orange, .38);
  $hover-border: rgba(orange, .6);
  $focused-border: rgba(orange, 1);

  @include mdc-text-field-bottom-line-color($idle-border);
  @include mdc-text-field-hover-bottom-line-color($hover-border);
  @include mdc-text-field-line-ripple-color($focused-border);
  @include mdc-text-field-ink-color(orange);
  @include mdc-text-field-label-color(rgba(orange, .87));
  @include mdc-text-field-outline-color($idle-border);
  @include mdc-text-field-hover-outline-color($hover-border);
  @include mdc-text-field-focused-outline-color($focused-border);
  @include mdc-text-field-helper-text-validation-color($hover-border);
  @include mdc-text-field-textarea-stroke-color($idle-border);
  @include mdc-text-field-caret-color($focused-border);
  @include mdc-text-field-icon-color($focused-border);

  // Example for --invalid textfield when helper text is not a validation message.
  @include mdc-text-field-helper-text-color(rgba(blue, .6));
}
// stylelint-enable selector-class-pattern

.demo-text-field-wrapper {
  margin-bottom: 8px;
}

.demo-tf-add-space {
  margin: 10px 0;
}